n = int(input())

for i in range(n):
    s = input()
    print('A' if s.count('A') > s.count('B') else 'B')
